﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using ProtoBuf.Message;

namespace Room
{
    public class RCUIMineGuide : RCUIMine
    {
        public RCUIMineGuide(RoomCharactor owner)
            : base(owner)
        {
            this.owner = owner;
            type = UIType.Mine;
        }

        public override void Init(TableFieldResource mine, TableFieldResourcePos minePos)
        {
            this.mine = mine;
            this.minePos = minePos;
            InitButton(() =>
            {
                StaticData.resId = mine.id;
                StaticData.resPosId = minePos.posId;


                {
                    var self = owner.charactorManager.GetSelfCharactor();
                    var ai = self.ai as RCAIActor;
                    ai.SwitchState(PlayerAIState.Mining);
                }

                UI.UIFieldRunMap.OpenGetResourceWaiting(() =>
                {
                    CSGuideMine msg = new CSGuideMine();
                    NetAPI.SendHttp(OpDefine.CSGuideMine, msg, (packet, bSuccess) =>
                      {
                      if (bSuccess)
                      {
                          var recv = packet.kBody as SCGuideMine;
                          UI.UIFieldRunMap.DisplayGetResource(recv.get);
                          //UI.UIFieldRunMap.DisplayGetResource(new ResultObject());
                    owner.charactorManager.DestroyCharactor(owner.name);

                    var self = owner.charactorManager.GetSelfCharactor();
                    var ai = self.ai as RCAIActor;
                    ai.SwitchState(PlayerAIState.Normal);
                          }
                      });

                });
            });
            SetButtonSprite("UI_yewai_biaoshi_wakuang");
        }

        protected override void OnClick()
        {
            
        }

    }
}
